package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.node.ForestNodeMerger;
import com.uchiha.nova.core.model.entity.WechaterEntity;
import com.uchiha.nova.core.model.vo.WechaterVO;
import com.uchiha.nova.mainService.service.IWechaterService;
import com.uchiha.nova.core.tool.util.SpringUtil;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 微信小程序用户信息  包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class WechaterWrapper extends BaseEntityWrapper<WechaterEntity, WechaterVO>  {
  
  IWechaterService wechaterService = SpringUtil.getBean(IWechaterService.class);
  
	public static WechaterWrapper build() {
		return new WechaterWrapper();
 	}

	@Override
	public WechaterVO entityVO(WechaterEntity wechaterEntity) {
		WechaterVO wechaterVO = new WechaterVO();
		BeanUtil.copyProperties(wechaterEntity, wechaterVO);

		return wechaterVO;
	}
	public List<WechaterVO> listVO(List<WechaterEntity> list) {
		List<WechaterVO> collect = list.stream().map(item -> {
            WechaterVO wechaterVO = new WechaterVO();
		    BeanUtil.copyProperties(item, wechaterVO);			
			return wechaterVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<WechaterVO> pageVO(IPage<WechaterEntity> pages) {
		IPage<WechaterVO> page = pages.convert(item->{
            WechaterVO wechaterVO = new WechaterVO();
		    BeanUtil.copyProperties(item, wechaterVO);			
			return wechaterVO;
		});
		return page;
	}
}
